package com.tjbklx1.thread.chap05.demo01;

import java.util.Random;

public class ConsumerThread extends Thread {

	private final Random random;
	private final Table table;

	public ConsumerThread(String name, long seed, Table table) {
		super(name);
		this.random = new Random(seed);
		this.table = table;
	}

	@Override
	public void run() {
		try {
			while (true) {
				String cake = table.take();
				Thread.sleep(random.nextInt(2000));
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
